package cn.iocoder.yudao.module.famous.doctor.dal.mysql.archives;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.archives.ArchivesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.archives.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 患者档案 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ArchivesMapper extends BaseMapperX<ArchivesDO> {

    default PageResult<ArchivesDO> selectPage(ArchivesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ArchivesDO>()
                .eqIfPresent(ArchivesDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(ArchivesDO::getIllnessIds, reqVO.getIllnessIds())
                .eqIfPresent(ArchivesDO::getMark, reqVO.getMark())
                .eqIfPresent(ArchivesDO::getAllergy, reqVO.getAllergy())
                .eqIfPresent(ArchivesDO::getClinic, reqVO.getClinic())
                .eqIfPresent(ArchivesDO::getImgs, reqVO.getImgs())
                .betweenIfPresent(ArchivesDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ArchivesDO::getUserId, reqVO.getUserId())
                .orderByDesc(ArchivesDO::getId));
    }

    default List<ArchivesDO> selectList(ArchivesExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ArchivesDO>()
                .eqIfPresent(ArchivesDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(ArchivesDO::getIllnessIds, reqVO.getIllnessIds())
                .eqIfPresent(ArchivesDO::getMark, reqVO.getMark())
                .eqIfPresent(ArchivesDO::getAllergy, reqVO.getAllergy())
                .eqIfPresent(ArchivesDO::getClinic, reqVO.getClinic())
                .eqIfPresent(ArchivesDO::getImgs, reqVO.getImgs())
                .betweenIfPresent(ArchivesDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ArchivesDO::getUserId, reqVO.getUserId())
                .orderByDesc(ArchivesDO::getId));
    }

    ArchivesDO selectOneBycard(@Param("userId") String creator,@Param("identityCard")  String identityCard,@Param("loginuserId") Long loginUserid);
}
